class TreeNode:
    def __init__(self,value=0,left=None,right=None):
        self.value=value
        self.left=left
        self.right=right
result=[]

def travel(root):
    result=[root.value,]
    if root ==None:
        return []
    q=[root]

    while q:
        node=q.pop(0)
        if node.left==None:
            return
        else:
            q.append(node.left)
            result.append(node.left.value)

        if node.right==None:
            return
        else:
            q.append(node.right)
            result.append(node.right.value)
            return result
    print(result)
    return result






root=TreeNode(1)
root.left=TreeNode(2)
root.right=TreeNode(3)
root.left.left=TreeNode(4)
root.left.right=TreeNode(5)
root.right.left=TreeNode(6)
root.right.right=TreeNode(7)

travel(root)
